#include "task.hpp"
#include "ringqueue.hpp"
void *produce(void *arg)
{
    ringqueue<calcTask> *queue = static_cast<ringqueue<calcTask> *>(arg);
    while (1)
    {
        int x, y;
        char op;
        cin >> x >> op >> y;
        calcTask t(x, y, op);
        cout << t.toTaskString() << endl;
        queue->push(t);
    }
}
void *consume(void *arg)
{
    ringqueue<calcTask> *queue = static_cast<ringqueue<calcTask> *>(arg);
    while (1)
    {
        calcTask t;
        queue->pop(t);
        cout << t() << endl;
    }
}
int main()
{
    pthread_t t1, t2;
    ringqueue<calcTask> *queue = new ringqueue<calcTask>();
    pthread_create(&t1, nullptr, produce, (void *)queue);
    pthread_create(&t2, nullptr, consume, (void *)queue);
    pthread_join(t1, nullptr);
    pthread_join(t2, nullptr);
    return 0;
}